<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        window.onload=function(){
            var a=document.getElementsByTagName("input");
            a[3].onclick=function(){
                var year=Number(a[0].value);
                var month=Number(a[1].value);
                if(month>0 && month<=12){
                    switch(month){
                        case 1:
                        case 3:
                        case 5:
                        case 7:
                        case 8:
                        case 10:
                        case 12:
                        a[2].value=31;
                        break;
                        case 4:
                        case 6:
                        case 9:
                        case 11:
                        a[2].value=30;
                        break;
                        case 2:
                            if(year%4==0&&year%100!=0 || year%400==0){
                                a[2].value=29;
                            }else{
                                a[2].value=28;
                                
                            }
                    }
                }else{
                    alert("月份请输入1-12");
                }
            }
            a[4].onclick=function(){
                a[0].value="";
                a[1].value="";
                a[2].value="";
        }
    }
    </script>
</head>
<body>
    <h2>请输入年和月，求当年当月有多少天</h2>
    <input type="text" placeholder="请输入年">年
    <input type="text" placeholder="请输入月">月有
    <input type="text" placeholder="点击确定求结果">天
    <input type="button" value="确定">
    <input type="button" value="重置">
</body>
</html>